<?php
/**
 * 其他备货
 * (model)
 */
namespace App\Models\Stocking;

use App\Models\Basics\SysArea;
use App\Models\Product\ProductSku;
use Illuminate\Database\Eloquent\Model;
class StockingSkuOther extends Model
{
    protected $table = 's_stocking_sku_other';

    protected $guarded = [];

    public static $_status = [
        1 => '待审批',
        2 => '驳回',
        3 => '通过',
    ];

    public function area(){
        return $this->belongsTo(SysArea::class,'area_id');
    }

    public function sku(){
        return $this->belongsTo(ProductSku::class,'psku_id');
    }

    protected static function boot()
    {
        parent::boot();

        static::deleting(function ($model){
            if($model->status == 3){
                throw new \Exception('已通过勿删除');
            }
        });
    }
}
